home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stddef.h>
-
-
- /* if you don't have stddef.h, use the following:
-
- typedef unsigned int size_t;
-
- #define offsetof(type,memb) (size_t)&(((type *)0L)->memb)
-
- */
-
- void main ( int argc, char *(argv[]) )
- {
-
- struct Employee {
- int EmpNo;
- char Name[31];
- float Salary;
- char SSNo [11]; /* incl. '-' */
- };
-
-
- printf ( "\n\n" );
-
- printf ( "Size of struct Employee: %d bytes.\n\n",
- sizeof (struct Employee ) );
-
- printf ( "The offset of EmpNo in the Employee struct is %u.\n",
- offsetof( struct Employee, EmpNo ) );
- printf ( "The offset of Name in the Employee struct is %u.\n",
- offsetof( struct Employee, Name ) );
- printf ( "The offset of Salary in the Employee struct is %u.\n",
- offsetof( struct Employee, Salary ) );
- printf ( "The offset of SSNo in the Employee struct is %u.\n",
- offsetof( struct Employee, SSNo ) );
-
- printf ( "\n\n" );
-
- return;
- }
-